|
|
|
|
|
|
|
Private Sub SetBitValue(HourList() As Byte, Day As Integer, Hour As _
Integer, Allow As Boolean)
Dim ByteIndex As Integer
Dim ByteMask As Integer
' Calculate the byte location
ByteIndex = Int(Hour / 8) + ((Day - 1) * 3)
' Calculate the mask to use for the logical operation
ByteMask = 2 ^ Int(Hour Mod 8)
Debug.Print ByteIndex
Debug.Print ByteMask
If Allow Then
HourList(ByteIndex) = HourList(ByteIndex) Or ByteMask
Else
HourList(ByteIndex) = HourList(ByteIndex) And (Not ByteMask)
End If
End Sub |
|
|
|
|
|
|
|
|
When testing the final program, I quickly found that I could not actually log on to the account I createdI kept getting the message that the account had expired. I found that I needed to make two changes: First, I had to ask the user administrator to add the new account to a group (you can do this through API functions, but I did not do so in this case). I also needed to set the usri2_acct_expires field to the constant TIMEQ_FOREVER (also 1) so that the account would never expire. |
|
|
|
|
|
|
|
|
The final function for adding a user is as follows: |
|
|
|
|
|
|
|
|
Private Sub Command1_Click()
Dim u12 As USER_INFO_2
Dim res As Long
Dim parm_err As Long
Dim username As String
Dim userpass As String
Dim HourList(20) As Byte
username = "Puzzle" & Chr$(0)
userpass = "pass" & Chr$(0)
ul2.usri2_name = StrPtr(username)
ul2.usri2_password = StrPtr(userpass)
ul2.usri2_priv = USER_PRIV_USER |
|
|
|
|
|